package com.my.demoo2.service.impl;

import com.my.demoo2.dao.UserInfoMapper;
import com.my.demoo2.entity.UserInfo;
import com.my.demoo2.service.UserInfoService;
import org.apache.catalina.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class UserInfoServiceImpl implements UserInfoService {
    @Autowired
    private UserInfoMapper userInfoMapper;
    @Override
    public List<UserInfo> getUser() {
        return userInfoMapper.getUserList();
    }

    @Override
    @Transactional
    public boolean update(UserInfo userInfo) {
        //修改用户
        int result = userInfoMapper.updateUser(userInfo);

//        "a".substring(5);

        //修改另一个用户
        UserInfo u=new UserInfo();
        u.setId(5L);
        u.setUserName("璐");
        userInfoMapper.updateUser(u);

        if(result==1){
            return true;
        }else{
            return false;
        }

    }
}
